import http from '../utils/http';

/**
 * 获取列表
 */
function getFormFolderTree(){
    return new Promise((resolve, reject) => {
        http("get",'/form/getFormFolderTree').then(res => {
            //console.log("ap-------:"+res);
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

/**
 * 获取列表
 */
function getForms(formFolderId){
    return new Promise((resolve, reject) => {
        http("get",'/form/getForms',{formFolderId:formFolderId}).then(res => {
            //console.log("ap-------:"+res);
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

function saveFolder(status, parentId, id, folderName) {
    return new Promise((resolve, reject) => {
        http("get",'/form/saveFolder',{status:status,parentId:parentId,id:id,folderName:folderName}).then(res => {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

//save  Form
function saveForm(formObj) {
    return new Promise((resolve, reject) => {
        http("post",'/form/saveForm',formObj).then(res => {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

function deleteForm(formId){
    return new Promise((resolve, reject) => {
        http("get",'/form/deleteForm',{formId:formId}).then(res => {
            //console.log("ap-------:"+res);
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })


}



function delFormFolder(formFolderId){
    return new Promise((resolve, reject) => {
        http("get",'/form/deleteFormFolder',{formFolderId:formFolderId}).then(res => {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

/**
 * 获取form表单
 */
function getForm(formId){
    return new Promise((resolve, reject) => {
        http("get",'/form/getForm',{formId:formId}).then(res => {
            //console.log("ap-------:"+res);
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

/**
 * showData
 */
function showData(formId){
    return new Promise((resolve, reject) => {
        http("get",'/olap/olapShowData',{formId:formId}).then(res =>
            {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

function olapRollUp(formId,pnFlagint,rowOrColFlg,rowNo,colNo,dimType){
    return new Promise((resolve, reject) => {
        //Integer formId, int pnFlagint, int rowOrColFlg, int rowNo, int colNo, int dimType
        http("get",'/olap/olapRollUp',{formId:formId,pnFlagint:pnFlagint,rowOrColFlg:rowOrColFlg,
            rowNo:rowNo,colNo:colNo,dimType:dimType
        }).then(res =>
        {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}

//olapDrillDown
function olapDrillDown(formId,pnFlagint,rowOrColFlg,rowNo,colNo,dimType){
    return new Promise((resolve, reject) => {
        //Integer formId, int pnFlagint, int rowOrColFlg, int rowNo, int colNo, int dimType
        http("get",'/olap/olapDrillDown',{formId:formId,pnFlagint:pnFlagint,rowOrColFlg:rowOrColFlg,
            rowNo:rowNo,colNo:colNo,dimType:dimType
        }).then(res =>
        {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}


//olapPageSwitch
function olapPageSwitch(formId,pageMembers){
    return new Promise((resolve, reject) => {

        let _o={formId:formId,pageMembers:pageMembers};
        //Integer formId, int pnFlagint, int rowOrColFlg, int rowNo, int colNo, int dimType
        http("post",'/olap/olapPageSwitch',_o).then(res =>
        {
            resolve (res);
        },error => {
            console.log("网络异常~",error);
            reject(error)
        })
    })
}





export {
    getFormFolderTree,getForms,getForm,showData,olapRollUp,
    saveFolder,delFormFolder,saveForm,deleteForm,olapDrillDown,
    olapPageSwitch
}

